{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " * Serving Flask app \"__main__\" (lazy loading)\n",
      " * Environment: production\n",
      "   WARNING: This is a development server. Do not use it in a production deployment.\n",
      "   Use a production WSGI server instead.\n",
      " * Debug mode: off\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/bootstrap.min.css HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/ie10-viewport-bug-workaround.css HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/cover.css HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/ie-emulation-modes-warning.js HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/jquery.min.js HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/bootstrap.min.js HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:25] \"\u001b[33mGET /static/ie10-viewport-bug-workaround.js%20 HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:55] \"\u001b[37mGET /dashboard HTTP/1.1\u001b[0m\" 200 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:56] \"\u001b[33mGET /static/bootstrap.min.css HTTP/1.1\u001b[0m\" 404 -\n",
      "127.0.0.1 - - [25/May/2022 18:33:56] \"\u001b[33mGET /static/ie10-viewport-bug-workaround.css HTTP/1.1\u001b[0m\" 404 -\n"
     ]
    }
   ],
   "source": [
    "from flask import Flask,render_template\n",
    "from bokeh.embed import components\n",
    "from bokeh.resources import INLINE\n",
    "from picture import mpg,vbar_demo\n",
    "\n",
    "app = Flask(__name__)\n",
    "\n",
    "\n",
    "@app.route('/')\n",
    "def index():\n",
    "    return render_template('index.html')\n",
    "\n",
    "@app.route('/dashboard')\n",
    "def dashboard():\n",
    "    '''\n",
    "    绘图模块picture -绘图函数 mpg\n",
    "    '''\n",
    "    p = mpg()\n",
    "    p2 = vbar_demo()\n",
    "    js_resources = INLINE.render_js()\n",
    "    css_resources = INLINE.render_css()\n",
    "    script, div = components([p,p2])\n",
    "\n",
    "    html = render_template(\n",
    "        'dashboard_base.html',\n",
    "        plot_script=script,\n",
    "        plot_div=div,\n",
    "        js_resources=js_resources,\n",
    "        css_resources=css_resources\n",
    "    )\n",
    "    return html\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    app.run()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
